/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.openmath.jome.ctrlview.bidim;

/**
 *
 * @author Mr.Sam
 */
import fr.ove.openmath.jome.ctrlview.bidim.*;
import fr.ove.openmath.jome.model.*;

/**
* The display of a symbol.
*
* @author © 2000 DIRAT Laurent
* @version 2.0  05/01/2000
*/
public class IconDisplay extends SymbolDisplay {
    /**
    * The constructor.<BR>
    * Instanciate a new display, with no displayable symbol associated. The symbol has to be set
    * by hand.
    * @param graphicContext the graphic context of the display.
    */
    public IconDisplay(GraphicContext graphicContext) {
        super(graphicContext);
        IconLayout layout = new IconLayout();
        layout.initDisplay(this);
        setLayout(layout);
    }
    
    /**
    * Builds the display of the formula tree structure.<BR>
    * This method has to be called when a formula tree structure has been created and the 
    * displays have not been associated yet.<BR>
    * As a prerequesit, the instance which call this method MUST have a corresponding instance
    * (a listener) in the formula tree structure (i.e. the formula tree structure we want to display).<BR>
    *
    public void buildDisplay() {
        Display childDisplay;
        FormulaTreeStructure ftsChild;
        Icon fts;
        int count;
        SubstitutedDisplayManager iconLM = (SubstitutedDisplayManager) getLayout();
        
        // On récupère l'élément de la FTS donc l'instance est le display.
        fts = (Icon) getListener();
        if (fts != null) { // Bon malgrè le prérequis, on fait le test quand même
            count = fts.getNbIconified();
            
            // On parcourre la liste des fils de la fts, pour leur associer le display qui va bien
            for (int i = 0; i < count; i++) {
                ftsChild = (FormulaTreeStructure) fts.getIconified(i);
                // Allocation du display
                childDisplay = getDisplayAllocator().allocateDisplay(getGraphicContext(), ftsChild);
                // On ajoute le nouveau display dans la liste des displays iconifiés
                iconLM.addSubstitutedDisplay(childDisplay);
                // On descend dans la fts pour poursuivre la construction des display
                childDisplay.buildDisplay();
            }
        }
    }
    */
}

